﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LWH.ByteProtocol
{
    /// <summary>
    /// 基础协议类，一般自定义类继承自此类
    /// </summary>
    public class AbstractProtocol : PackageProperty
    {
        /**
        * 存放byte数据数组
        */
        protected byte[] mData;


        public AbstractProtocol(byte[] data = null) : base(null)
        {
            if(data!=null)
            {
                mData = data;
            }
            
        }


        override public int getOffset()
        {
            return 0;
        }


        override protected internal int getOwnerOffset()
        {
            return 0;
        }


        override public byte[] getData()
        {
            return mData;
        }


        override public void setData(byte[] data, int offset, int length)
        {
            mData=ByteConverter.copyOfRange(data, offset, offset + length);
        }



        override protected internal byte[] getSrcData()
        {
            return mData;
        }
    }
}
